/**
 * @file rank/elementary/luogu1150/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/7 14:07:28
 **/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
  // High rating and good luck!
  int total = 0;
  int bottles, k;
  int caps = 0;
  cin >> bottles >> k;
  while (bottles) {
    caps += bottles;
    total += bottles;
    bottles = caps / k;
    caps -= bottles * k;
  }
  cout << total << endl;
}
